#include <stdio.h>

int main(){
	 
   	int wine;//每次倒入的酒
	int glass_row[100][100]={0};//香槟塔
	int i=0,t=0;
	
	int sign=1;
	while(sign!=0){
	printf("input:1 or 0 (1:pour wine 0:finish):");
	scanf("%d",&sign);
	switch(sign){
	case 1://倒酒
	printf("input:");
	scanf("%d",&wine);	
    glass_row[0][0]+=wine;
	
	for(i=0;i<10;i++){
	for(t=0;t<=i;t++){
			
		if(glass_row[i][t]>100){//判断酒杯是否已满
			glass_row[i+1][t]+=(glass_row[i][t]-100)/2;//将溢出的酒平均分入下方两个酒杯
			glass_row[i+1][t+1]+=(glass_row[i][t]-100)/2;
			glass_row[i][t]=100;
		}	
			
    }
	}
	int p;
	for(i=0;i<10;i++){//打印香槟塔
	for(p=0;p<(10-i);p++){
		printf("  ");	
		}
		for(t=0;t<=i;t++){	
		if(glass_row[i][t]==100){
			printf("%d ",glass_row[i][t]);
		}else if(glass_row[i][t]>9){
			printf(" %d ",glass_row[i][t]);
		}else if(glass_row[i][t]>0){
	     	printf(" %d  ",glass_row[i][t]);
		}else if(glass_row[i][t]==0){
	     	printf("    ");
		}
		
			
	}
	printf("\n");
	}
	break;
	case 0://停止
    printf("END\n");
	break;
			
	}
	
    }
		return 0;
}

	
	
	
	


